<?php


namespace app\api\model\lottery;

use app\common\model\lottery\Log as LogModel;

class Log extends LogModel
{
    public static function addLog($user_id, $lottery_id, $lottery_goods_id)
    {
        return self::create([
            'user_id' => $user_id,
            'lottery_id' => $lottery_id,
            'lottery_goods_id' => $lottery_goods_id,
            'wxapp_id' => static::$wxapp_id,
            'create_time' => time()
        ]);
    }

    public static function getUserLog($user_id, $lottery_id)
    {
        return self::with(['user', 'lotteryGoods'])
            ->where('user_id', $user_id)
            ->where('lottery_id', $lottery_id)
            ->order('create_time desc')
            ->select();
    }
}